package com.kehutong.admin.service;

import com.kehutong.admin.entity.Corp;
import com.kehutong.common.DoveClient;
import com.kehutong.common.entity.Root;
import com.kehutong.common.util.Token;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import org.coraframework.mvc.webservice.WebService;
import org.coraframework.orm.Pool;
import org.coraframework.orm.jdbc.JdbcSession;

import java.util.List;

/**
 * 企业信息服务类
 *
 * @author: liukunlong
 * @date: 2021-03-29 10:52
 */
@WebService("/admin/service/corp")
public class CorpService {

    @Inject
    private DoveClient doveClient;

    @Inject
    private JdbcSession jdbcSession;

    @ReqMapping("/get")
    public Object get(Corp item) {
        return item;
    }

    @ReqMapping("/list")
    public Object list(JSONObject jsonObject){
        List<Corp> list = jdbcSession.findArray(Corp.class)
                .eq(jsonObject,"id")
                .eq("deleted", false)
                .exe();

        return list;
    }

    @ReqMapping("/delete")
    public Object delete(Corp corp) {
        corp.setDeleted(true);
        jdbcSession.updateById(corp);

        return Result.success();
    }
}
